<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增通知')" />
	<th:block th:include="include :: ztree-css" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-post-add">
			<div class="form-group">
				<label class="col-sm-3 control-label ">通知名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="typeName" id="typeName" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">权限字符：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="createBy" id="createBy" required>
					<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 控制器中定义的权限字符，如：@RequiresRoles("")</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">显示顺序：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="typeSort" id="typeSort" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">状态：</label>
				<div class="col-sm-8">
			        <label class="toggle-switch switch-solid">
                        <input type="checkbox" name="status" id="status" checked>
                        <span></span>
                    </label>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">通知时间：</label>
				<div class="col-sm-8">
					<input class="form-control" type="date" name="createTime" id="createTime" required>
				</div>
			</div>

		</form>
	</div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: ztree-js" />
	<script type="text/javascript">

		
		$("#form-post-add").validate({
			rules:{
				onkeyup: false,
				typeName:{
					remote: {
		                url: ctx + "cms/type/checkPostNameUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	"typeName" : function() {
		                		return $.common.trim($("#typeName").val());
		                    }
		                },
		                dataFilter: function(data, type) {
		                	return $.validate.unique(data);
		                }
		            }
				},

				roleSort:{
					digits:true
				},
			},
			messages: {
		        "typeName": {
		            remote: "通知名称已经存在"
		        }

		    },
		    focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	// add();
				var status = $("input[id='status']").is(':checked') == true ? 0 : 1;
				console.log(status)
				$("#status").val(status);
	        	$.operate.save("/cms/type/add",$("#form-post-add").serialize())
	        }
	    }
	</script>
</body>
</html>
